import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home
  },
  //订单完成
  {
    path: '/orderFeedback',
    name: 'orderFeedback',
    meta: {
      title: '订单完成'
    },
    component: () => import(/* webpackChunkName: "orderFeedback" */ '../views/order/feedback.vue')
  },
  //城市定位
  {
    path: '/citylocation',
    name: 'citylocation',
    meta: {
      title: '城市定位'
    },
    component: () => import(/* webpackChunkName: "cityloc" */ '../views/city/location.vue')
  },
  //搜索主页
  {
    path: '/search',
    name: 'search',
    component: () => import(/* webpackChunkName: "search" */ '../views/search/search.vue')
  },
  //海报主图
  {
    path: '/poster',
    name: 'poster',
    component: () => import(/* webpackChunkName: "poster" */ '../views/poster/poster.vue')
  },
  //海报上传的
  {
    path: '/posterUpload',
    name: 'posterUpload',
    component: () => import(/* webpackChunkName: "posterUpload" */ '../views/poster/posterUpload.vue')
  },
  //海报上传的
  {
    path: '/share',
    name: 'share',
    meta: {
      title: '专属海报'
    },
    component: () => import(/* webpackChunkName: "share" */ '../views/poster/share.vue')
  },
  //提现记录
  {
    path: '/cashRecord',
    name: 'cashRecord',
    meta: {
      title: '提现记录'
    },
    component: () => import(/* webpackChunkName: "cashRecord" */ '../views/admin/cashRecord.vue')
  },
  //提现记录
  {
    path: '/incomeRecord',
    name: 'incomeRecord',
    meta: {
      title: '收益明细'
    },
    component: () => import(/* webpackChunkName: "incomeRecord" */ '../views/admin/incomeRecord.vue')
  },
  //提现成功
  {
    path: '/cashfeedback',
    name: 'cashfeedback',
    meta: {
      title: '提现成功'
    },
    component: () => import(/* webpackChunkName: "cashfeedback" */ '../views/admin/cashfeedback.vue')
  },
  //提现
  {
    path: '/cashOrder',
    name: 'cashOrder',
    meta: {
      title: '提现'
    },
    component: () => import(/* webpackChunkName: "cashOrder" */ '../views/admin/cashOrder.vue')
  },
  //绑定支付宝
  {
    path: '/bandAlipay',
    name: 'bandAlipay',
    meta: {
      title: '绑定支付宝'
    },
    component: () => import(/* webpackChunkName: "bandAlipay" */ '../views/admin/bandAlipay.vue')
  },
  //绑定支付宝
  {
    path: '/bandAlipayNext',
    name: 'bandAlipayNext',
    meta: {
      title: '绑定支付宝'
    },
    component: () => import(/* webpackChunkName: "bandAlipayNext" */ '../views/admin/bandAlipayNext.vue')
  },
  //联系客服
  {
    path: '/contact',
    name: 'contact',
    meta: {
      title: '联系客服'
    },
    component: () => import(/* webpackChunkName: "contact" */ '../views/admin/contact.vue')
  },
  //投诉建议
  {
    path: '/suggest',
    name: 'suggest',
    meta: {
      title: '投诉建议'
    },
    component: () => import(/* webpackChunkName: "suggest" */ '../views/admin/suggest.vue')
  },
  //关于我们
  {
    path: '/about',
    name: 'about',
    meta: {
      title: '关于我们'
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/admin/about.vue')
  },
  //我的订单
  {
    path: '/myOrders',
    name: 'myOrders',
    meta: {
      title: '我的订单'
    },
    component: () => import(/* webpackChunkName: "myOrders" */ '../views/order/myOrders.vue')
  },
  //订单详情
  {
    path: '/orderDetail',
    name: 'orderDetail',
    meta: {
      title: '订单详情'
    },
    component: () => import(/* webpackChunkName: "orderDetail" */ '../views/order/orderDetail.vue')
  },
  //申请退款
  {
    path: '/refund',
    name: 'refund',
    meta: {
      title: '申请退款'
    },
    component: () => import(/* webpackChunkName: "refund" */ '../views/order/refund.vue')
  },
  //请求后台示例页
  {
    path: '/getData',
    name: 'getData',
    meta: {
      title: '请求后台示例页'
    },
    component: () => import(/* webpackChunkName: "getData" */ '../views/getData.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  next();
})
export default router
